<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>课堂签到</title>
    <link rel="shortcut icon" href="../../static/img/icon.svg">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
    <link rel="stylesheet" href="../../static/html5up-forty/assets/css/main.css"/>
    <noscript>
        <link rel="stylesheet" href="../../static/html5up-forty/assets/css/noscript.css"/>
    </noscript>
</head>
<body class="is-preload">
<div id="wrapper">

    <!-- Header -->
    <header id="header" class="alt">
        <a th:href="@{|/index|}" class="logo"><strong>Jli</strong> <span>by my</span></a>
        <nav>
            <p style="font-size: 15px" th:text="${session.student.getName()}"></p>
            <a href="#menu">菜单</a>
        </nav>
    </header>

    <!-- Menu -->
    <nav id="menu">
        <ul class="links">
            <li><a th:href="@{|/index|}">主页</a></li>
            <li><a href="#">编辑信息</a></li>
            <li><a href="#">修改密码</a></li>
        </ul>
        <ul class="actions stacked">
            <li><a th:href="@{|/studentLogout|}" class="button fit">退出登录</a></li>
        </ul>
    </nav>

    <!-- Main -->
    <div class="main">
        <div class="inner" style="width: 25%;">
            <section>
                <div class="fields">
                    <div class="field">
                        <label for="code">输入6位验证码</label>
                        <input type="text" name="code" id="code">
                    </div>
                </div>
                <br>
                <ul class="actions">
                    <li><a href="javascript:void(0)" class="button primary" onclick="sign()">签到</a></li>
                    <li><a th:href="@{|/index|}" class="button">返回</a></li>
                </ul>
            </section>
        </div>
    </div>
</div>

<!-- Scripts -->
<script src="../../static/html5up-forty/assets/js/jquery.min.js"></script>
<script src="../../static/html5up-forty/assets/js/jquery.scrolly.min.js"></script>
<script src="../../static/html5up-forty/assets/js/jquery.scrollex.min.js"></script>
<script src="../../static/html5up-forty/assets/js/browser.min.js"></script>
<script src="../../static/html5up-forty/assets/js/breakpoints.min.js"></script>
<script src="../../static/html5up-forty/assets/js/util.js"></script>
<script src="../../static/html5up-forty/assets/js/main.js"></script>
<script>
    function sign(){
        let code = $("#code").val();
        if (code !== ""){
            $.ajax({
                type: "GET",
                url: "webapi/student/sign",
                data: {
                    code:code
                }
            }).done(function (data){
                if (data === 1){
                    alert("签到成功");
                    window.location.href = "index";
                } else if (data === 2){
                    alert("还没有发布签到")
                } else if (data === -1){
                    alert("签到失败");
                }
            })
        }
    }
</script>
</body>
</html>